package com.ahcfl.service.impl;

import com.ahcfl.dao.FileMapper;
import com.ahcfl.dto.PageBean;
import com.ahcfl.pojo.File;
import com.ahcfl.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FileServiceImpl implements FileService {

    @Autowired
    private FileMapper fileMapper;

    @Override
    public void saveFile(File file) {

        fileMapper.saveFile(file);
    }

    @Override
    public PageBean<File> findFileByPage(int pageNum, int pageSize) {

        int start = (pageNum-1)*pageSize;

        int total = fileMapper.findAllFileCount();


        List<File> fileList =  fileMapper.findFileByPage(start,pageSize);

        PageBean<File> pageBean = new PageBean<>(fileList,total);

        return pageBean;
    }
}
